//
//  CheckTableViewController.m
//  11210
//
//  Created by student on 16/3/4.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "CheckTableViewController.h"

@interface CheckTableViewController ()
@property(nonatomic,strong)NSArray *list;
@property(nonatomic,strong)NSIndexPath *lastindexpath;
@property(nonatomic,strong)NSMutableArray *pathcount;
@end

@implementation CheckTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"电影列表";
    self.list=@[@"Who Hash",
                @"Bubba Gump Shrimp Étouffée", @"Who Pudding", @"Scooby Snacks",
                @"Everlasting Gobstopper", @"Green Eggs and Ham", @"Soylent Green",
                @"Hard Tack", @"Lembas Bread", @"Roast Beast", @"Blancmange",@"Who Hash",
                @"Bubba Gump Shrimp Étouffée", @"Who Pudding", @"Scooby Snacks",
                @"Everlasting Gobstopper", @"Green Eggs and Ham", @"Soylent Green",
                @"Hard Tack", @"Lembas Bread", @"Roast Beast", @"Blancmange"];
    NSLog(@"%@",self.lastindexpath);
    self.pathcount=[[NSMutableArray alloc]init];
    for(int i=0;i<self.list.count;i++)
    {
        
        [self.pathcount addObject:@0];
    }
}


#pragma mark - Table view data source



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return self.list.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.textLabel.text=self.list[indexPath.row];
    if(self.lastindexpath.row==indexPath.row)
    {
        
        cell.accessoryType=UITableViewCellAccessoryCheckmark;
    }
    else
    {
        cell.accessoryType=UITableViewCellAccessoryNone;
    }

    
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   
    self.pathcount[indexPath.row]=@1;
   
    
    UITableViewCell *lastcell=[tableView cellForRowAtIndexPath:self.lastindexpath];
    lastcell.accessoryType=UITableViewCellAccessoryNone;
    
    UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath];
    cell.accessoryType=UITableViewCellAccessoryCheckmark;
    self.lastindexpath=indexPath;
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    
}


@end
